package data

import (
	"context"
	"demo/internal/biz/repo"
	"demo/internal/dao"
	"demo/internal/model/entity"
)

type userRepo struct {
	data *Data
}

func NewUserRepo(data *Data) repo.UserRepo {
	return &userRepo{
		data: data,
	}
}

func (t *userRepo) CreateUser(ctx context.Context, name string) error {
	_, err := t.data.Orm.Insert(ctx, dao.User.Table(), entity.User{
		Name: name,
	})
	return err
}

func (t *userRepo) GetUser(ctx context.Context, name string) error {
	 var u entity.User
	err := t.data.Orm.Model(dao.User.Table()).Where(dao.User.Columns().Name, "name").Scan(&u)
	return err
}
